<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/js-test-resources/gc.js"></script>
<script src="/js-test-resources/js-test.js"></script>
<script>
'use strict';

// This is a Blink-specific test because it involves garbage collection.
for (const constructor of [TextEncoderStream, TextDecoderStream]) {
  promise_test(async () => {
    const transform = new constructor();
    if (typeof GCController !== 'undefined')
      await asyncGC();
    // This test will generally crash on the next line if it fails.
    assert_true(transform.readable instanceof ReadableStream,
                'readable side must still be set');
    assert_true(transform.writable instanceof WritableStream,
                'writable side must still be set');
  }, `${constructor.name} readable and writable properties must survive GC`);
}
</script>
